package com.sinoglobal.ningxia.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;
import com.sinoglobal.ningxia.beans.AreaQuListVo;

/**
 * @Title: ScreenListAdapter.java
 * @Package com.sinoglobal.searchingforfood.fragment
 * @Description: TODO(用一句话描述该文件做什么)
 * @author czz
 * @date 2014-5-13 下午1:58:29
 */
public class ScreenListAdapter extends BaseAdapter implements ListAdapter {
	private Context context;
	public int num = 0;
	private ArrayList<AreaQuListVo> areaListVo;

	public ScreenListAdapter(Context context) {
		this.context = context;
	}

	public ArrayList<AreaQuListVo> getAreaListVo() {
		return areaListVo;
	}

	public void setAreaListVo(ArrayList<AreaQuListVo> areaListVo) {
		this.areaListVo = areaListVo;
	}

	@Override
	public int getCount() {
		return areaListVo.size() + 1;
	}

	@Override
	public AreaQuListVo getItem(int position) {
		return areaListVo.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = LayoutInflater.from(context).inflate(R.layout.screenlist_item, null);
		if (num == position) {
			convertView.setBackgroundResource(R.drawable.spanner_content_bg_selected);
		}
		TextView screnlist_tv = (TextView) convertView.findViewById(R.id.screnlist_tv);
		if (position == 0) {
			screnlist_tv.setText(context.getString(R.string.act_listview_itemTitle));
		} else {
			screnlist_tv.setText(areaListVo.get(position - 1).getZone_name());
		}
		return convertView;
	}
}
